<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>够达管理平台</title>
    <link rel="stylesheet" href="${ctx}/css/cms/login.css">
    <script type="text/javascript" src="${ctx}/js/common/jquery-1.8.0.js"></script>
</head>
<body>

<div class="login">
    <div class="l-header">
        <h1>够达管理平台</h1>
    </div>
    <div class="l-content">
        <form method="POST" id="inputForm">
            <div class="loginWrap">
                <p><input type="text" class="username" name="email" id="email" placeholder="账号"/></p>

                <p><input type="password" class="password" name="passwd" id="passwd" placeholder="密码"/></p>
                <input type="button" class="loginBtn" value="登陆" id="login_submit"/>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    if (window.top != window.self) {
        window.top.location.href = window.self.location.href;
    }

    $("#login_submit").on("click", function () {
        if ($("#email").val() == '') {
            alert("请填写用户名");
            return;
        }
        if ($("#passwd").val() == '') {
            alert("请填写密码");
            return;
        }
        $.ajax({
            type: "get",
            url: "${ctx}/login",
            data: $('#inputForm').serialize(),
            dataType: "json",
            success: function (json) {
                if ("200" === json["code"]) {
                    alert("登录成功!");
                    window.location.href = "${ctx}/index";
                } else {
                    alert("用户名或者密码错误!");
                }
            },
            error: function (json) {
                alert("登录失败!");
            }
        });
    });

</script>
</body>
</html>